package com.engine4cloud.tdf.supervision.controller.inner;

import cn.hutool.core.collection.CollUtil;
import com.engine4cloud.tdf.common.core.util.R;
import com.engine4cloud.tdf.common.data.web.response.PageInfo;
import com.engine4cloud.tdf.common.log.annotation.SysLog;
import com.engine4cloud.tdf.common.security.annotation.Inner;
import com.engine4cloud.tdf.supervision.dto.create.RcglVerificationEvidenceCreateDTO;
import com.engine4cloud.tdf.supervision.dto.query.RcglVerificationEvidenceQueryDTO;
import com.engine4cloud.tdf.supervision.dto.result.RcglVerificationEvidenceResultDTO;
import com.engine4cloud.tdf.supervision.dto.update.RcglVerificationEvidenceUpdateDTO;
import com.engine4cloud.tdf.supervision.service.RcglVerificationEvidenceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

/**
 * 核实取证
 *
 * @author wenjie
 * @date 2024-04-26 14:41:32
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/inner/verification/evidence")
@Tag(description = "VerificationEvidence", name = "日常管理-核实取证-inner")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class RcglVerificationEvidenceInnerController {

    private final RcglVerificationEvidenceService verificationEvidenceService;

    /**
     * 分页查询
     *
     * @param dto 核实取证
     * @return R<PageInfo < RcglVerificationEvidenceResultDTO>>
     */
    @Inner
    @Operation(summary = "分页查询", description = "分页查询")
    @PostMapping("/page")
    public R<PageInfo<RcglVerificationEvidenceResultDTO>> getPageList(@Valid @RequestBody RcglVerificationEvidenceQueryDTO dto) {
        return R.ok(verificationEvidenceService.getPageList(dto, dto));
    }


    /**
     * 通过id查询核实取证
     *
     * @param id id
     * @return R
     */
    @Inner
    @Operation(summary = "通过id查询", description = "通过id查询")
    @GetMapping("/{id}")
    public R<RcglVerificationEvidenceResultDTO> getById(@PathVariable("id") Long id) {
        return R.ok(verificationEvidenceService.getById(id));
    }

    /**
     * 新增核实取证
     *
     * @param dto 核实取证
     * @return R
     */
    @Inner
    @Operation(summary = "新增核实取证", description = "新增核实取证")
    @SysLog("新增核实取证")
    @PostMapping
    public R<Boolean> create(@Valid @RequestBody RcglVerificationEvidenceCreateDTO dto) {
        return R.ok(verificationEvidenceService.create(dto));
    }

    /**
     * 修改核实取证
     *
     * @param dto 核实取证
     * @return R
     */
    @Inner
    @Operation(summary = "修改核实取证", description = "修改核实取证")
    @SysLog("修改核实取证")
    @PutMapping
    public R<Boolean> update(@Valid @RequestBody RcglVerificationEvidenceUpdateDTO dto) {
        return R.ok(verificationEvidenceService.update(dto));
    }

    /**
     * 通过id删除核实取证
     *
     * @param ids id列表
     * @return R
     */
    @Inner
    @Operation(summary = "通过id删除核实取证", description = "通过id删除核实取证")
    @SysLog("通过id删除核实取证")
    @DeleteMapping
    public R<Boolean> removeById(@RequestBody Long[] ids) {
        return R.ok(verificationEvidenceService.removeBatchByIds(CollUtil.toList(ids)));
    }
}